# Maintainer: Sarah Ottinger

_realname=trustme
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.6.0
pkgrel=1
pkgdesc='Library for fake certificate authority (CA) to generate fake TLS certs (mingw-w64)'
arch=('any')
url="https://trustme.readthedocs.io/"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest" "${MINGW_PACKAGE_PREFIX}-python-pyopenssl" "${MINGW_PACKAGE_PREFIX}-python-service_identity")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "${MINGW_PACKAGE_PREFIX}-python-cryptography")
source=("https://github.com/python-trio/trustme/archive/v${pkgver}.tar.gz")
sha256sums=('9c3e13bb31bedbc819486dff7aa7a78ffae21a628d034f18dba36851ef7321ff')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-$pkgver" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  PYTHONPATH=. ${MINGW_PREFIX}/bin/py.test
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE.MIT "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.MIT"
  install -Dm 644 README.rst -t "${pkgdir}${MINGW_PREFIX}/share/doc/python-${_realname}"
}
